package cn.com.ejiakanghu.aop;

import com.github.pagehelper.PageHelper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author wj
 * @date 2021/9/10 13:36
 */
@Component
@Aspect
public class PageHelperAop {

    private final Logger logger = LoggerFactory.getLogger(PageHelperAop.class);
    /**
     * 切点 匹配service下所有方法
     */
    @Pointcut("execution(* cn.com.ejiakanghu.service..*.*(..))")
    public void pagehelper() {}


    @After("pagehelper()") //在切入点的方法run之前要干的
    public void clearBeforeBack(JoinPoint joinPoint) {
        PageHelper.clearPage();
        // 记录下请求内容
        logger.info("进入了切点：{}","删除未使用pagehelper记录");

    }
}
